<template>
  <div>
    <div style="margin: 20px 0"></div>
    <div>
      <FormPanel ref="formPanel" :list="formList" :cols="3" :labelWidth="105" :isSubmitBtn="false" />
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button @click="closeDrawer()">关 闭</multiuse-button>
    </div>
  </div>
</template>

<script>
import config from '@/assets/js/config';
export default {
  props: ['rowData'],
  data() {
    return {
      formList: this.createFromList(),
      fileList: []
    };
  },
  mounted() {
    //console.log('初始化',this.rowData.attachmentUrl,this.rowData.attachmentName);
    if (this.rowData) {
      let url = this.rowData.attachmentUrl;
      if (url) {
        let name = this.rowData.attachmentName;
        let initData = {
          name: name,
          url: url
        };
        this.fileList.push(initData);
      }
      this.formList.find(item => item.fieldName === 'fileList').initialValue = this.fileList;
    }
  },
  created() {},
  methods: {
    createFromList() {
      return [
        {
          type: 'UPLOAD_FILE',
          label: '附件上传',
          fieldName: 'fileList',
          initialValue: [],
          disabled: true,
          upload: {
            actionUrl: `${config.uploadUrl}/api/file/oss/upload`,
            limit: 1
          },
          selfCols: 3
        }
      ];
    },
    async closeDrawer() {
      this.$emit('close');
    }
  }
};
</script>

<style></style>
